package com.lenovo.codestatreport.jira.controller;

import com.lenovo.codestatreport.jira.model.Issues;
import com.lenovo.codestatreport.jira.service.IssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author Howie Lu
 * @version Created at 2019/05/20
 * @version Updated at 2019/05/20
 */
@Controller
@RequestMapping("/issue")
public class IssueController {
    @Autowired
    IssueService issueService;

    @RequestMapping("/FindAllIssueRecordsByTime")
    @ResponseBody
    public List<Issues> findAllIssueRecords(HttpServletRequest request){
        String start = request.getParameter("start");
        String end = request.getParameter("end");
        return issueService.getAllIssueRecords(start, end);
    }

    @RequestMapping("/FindIssuesInProject")
    @ResponseBody
    public List<String> findIssuesInProject(HttpServletRequest request){
        String projectkey = request.getParameter("projectkey");
        return issueService.findIssuesInProject(projectkey);
    }
}
